package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.CremationTimeSegmentEntity;
import com.jinmdz.fmis.mapper.mapper.provider.CremationTimeSegmentProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 火化预约时间段表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface CremationTimeSegmentMapper {

    /**
     * 增加CremationTimeSegment
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = CremationTimeSegmentProvider.class, method = "insertCremationTimeSegment")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertCremationTimeSegment(@Param("entity") CremationTimeSegmentEntity entity);

    /**
     * 删除CremationTimeSegment
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update cremation_time_segment set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForCremationTimeSegment(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改CremationTimeSegment
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = CremationTimeSegmentProvider.class, method = "updateCremationTimeSegment")
    void updateCremationTimeSegment(@Param("entity") CremationTimeSegmentEntity entity);

    /**
     * 查询CremationTimeSegment实体
     *
     * @param id 主键
     * @return CremationTimeSegmentEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,furnace_type_code,appointment_time_segment,sort,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from cremation_time_segment where id = #{id} and deleted = 0 limit 1 ")
    CremationTimeSegmentEntity getCremationTimeSegmentById(@Param("id") Integer id);

    /**
     * 查询CremationTimeSegment列表
     *
     * @param entity 数据实体
     * @return CremationTimeSegmentEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = CremationTimeSegmentProvider.class, method = "listCremationTimeSegment")
    ArrayList<CremationTimeSegmentEntity> listCremationTimeSegment(@Param("entity") CremationTimeSegmentEntity entity);
}